package dream.util;

import dream.pojo.AppVar;
import dream.pojo.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 得到当前登录的用户
 */
public class SessionUtils {
    public static User getLoginUser(HttpServletRequest req){
        User user = null;
        HttpSession session= req.getSession(false);
        if(session!=null && session.getAttribute(AppVar.SESSION_USERINFO_KEY)!=null){
            user = (User) session.getAttribute(AppVar.SESSION_USERINFO_KEY);
        }
        return user;
    }
}
